package com.oil.petro.eshop.service;

import com.oil.petro.eshop.dao.CategoryDAO;
import com.oil.petro.eshop.dao.ManufacturerDAO;
import com.oil.petro.eshop.entity.Manufacturer;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional()
public class ManufacturerServiceImpl implements ManufacturerService {

    @Autowired
    ManufacturerDAO manufacturerDAO;

    @Override
    public Manufacturer getManufacturer(int id) {
        return manufacturerDAO.get(id);
    }

    @Override
    public void deleteManufacturer(Manufacturer manufacturer) {
        manufacturerDAO.delete(manufacturer);
    }

    @Override
    public int saveManufacturer(Manufacturer manufacturer) {
        return manufacturerDAO.save(manufacturer);
    }

    @Override
    public void updateManufacturer(Manufacturer manufacturer) {
        manufacturerDAO.update(manufacturer);
    }

    @Override
    public List<Manufacturer> getManufacturerList() {
        return manufacturerDAO.getList();
    }

    public int getManufacturerIdByName(String name) {
        return manufacturerDAO.getId(name);
    }
}
